package FourArithmeticOperations;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by dell on 2017/9/22.
 */
public class Bag<T> implements BagInterface<T> {
    ArrayList list= new ArrayList();

    @Override
    public int getCurrentSize() {
        int number = 0;
        number = list.size();
        return number;
    }

    @Override
    public boolean isEmpty() {
        if (list.isEmpty());
        System.out.println("Nothing");
        return false;
    }

    @Override
    public boolean add(T newEntry) {
        list.add(newEntry);
        return false;
    }

    @Override
    public T remove() {
        return null;
    }

    @Override
    public boolean remove(T anEntry) {
        String number;
        if (list!=null);
        System.out.println("Which one do you want remove?");
        list.remove(anEntry);
        return false;
    }

    @Override
    public void clear() {
        list.clear();
    }

    @Override
    public int getFrequencyOf(T anEntry) {
        int num = 0;
        for (int i= 0;i<list.size();i++)
            if (list.get(i).equals(anEntry))
                num++;
        return 0;
    }

    @Override
    public boolean contains(T anEntry) {
        list.contains(anEntry);
        return false;
    }

    @Override
    public String toString() {
        return "Bag{" +
                "list=" + list +
                '}';
    }

    @Override
    public T[] toArray() {
        return (T[]) list.toArray();
    }
}
